﻿using Infragistics.Windows.DockManager.Events;
using System.Collections.Generic;
using VNet.VisiSuite.Controls;
using VNet.VisiSuite.VisiAdmin.Controls;
using VNet.VisiSuite.VisiAdmin.ViewModels;

namespace VNet.VisiSuite.VisiAdmin.Views
{
    public partial class PlantView : VisiPage
    {
        public PlantView()
        {
            InitializeComponent();
            dataGrid.InitializeRecord += dataGrid_InitializeRecord;
        }

        private void dataGrid_InitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e)
        {
            if (!e.ReInitialize)
            {
                if (e.Record.FieldLayout.Key.ToString() == "Plants")
                    e.Record.IsExpanded = true;
            }
        }

        private void PaneDragStarting(object sender, PaneDragStartingEventArgs e)
        {
            e.Cancel = true;
        }

        public override IList<VNetMenuItem> BottomMenuItems()
        {
            var viewModel = DataContext as PlantViewModel;
            if (viewModel == null) return null;

            return viewModel.BottomMenuItems;
        }
    }
}
